package epam.bank.repository;

import epam.bank.domain.Payment;
import org.springframework.stereotype.Repository;
import epam.bank.repository.api.IPaymentRepository;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: dima
 * Date: 10.03.13
 * Time: 1:56
 * To change this template use File | Settings | File Templates.
 */

@Repository("paymentRepository")
public class PaymentRepositoryImpl extends GenericCRUDRepositoryImpl<Payment> implements IPaymentRepository {

    public PaymentRepositoryImpl() {
        super(Payment.class);
    }

    @Override
    protected void beforeEntityDelete(Payment entity) {
        //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
//    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    public List<Payment> getPaymentsByInvoice(Long invoiceId) throws IllegalArgumentException {
        if (invoiceId == null) {
            throw new IllegalArgumentException(
                    "Parameter Invoice - invoiceID is null");
        }
        return executeQuery("Payment.getByPayment", true, false, invoiceId);
    }
}
